package com.wyd.System.Controller;


import com.wyd.System.Bean.Institute;
import com.wyd.System.Service.InstituteService;
import com.wyd.handler.BusinessException;
import com.wyd.response.Result;
import com.wyd.response.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 文永达
 * @since 2020-12-05
 */
@Api(value = "学院")
@RestController
@RequestMapping("/System/institute")
public class InstituteController {

    @Autowired
    private InstituteService instituteService;

    @ApiOperation(value = "查询学院及人数",notes = "从学院表中分组查询学生人数")
    @GetMapping("/findInstitute")
    public Result findInstitute(){
        List<Institute> institutes=instituteService.findInstitute();
        if(institutes.size()==0){
            throw new BusinessException(ResultCode.INSTITUTE_NOT_FOUND_EXCEPTION.getCode(),
                    ResultCode.INSTITUTE_NOT_FOUND_EXCEPTION.getMessage());
        }
        return Result.ok().data("institutes",institutes);
    }
}

